#include <stdio.h>
#include <stdlib.h>

#define ROOK	010
#define BISHOP	04

const int rook_dir_i[4]		= { -1, 1, 0, 0 };
const int rook_dir_j[4]		= { 0, 0, -1, 1 };

const int bishop_dir_i[4]	= { 1, -1, -1, 1 };
const int bishop_dir_j[4]	= { 1, -1, 1, -1 };

void
_print_map(const int array[8][8])
{
	register short i, j;
	for (i = 0; i < 8; ++i) {
		for (j = 0; j < 8; ++j)
			(void) fprintf(stderr, "%2d", array[i][j]);
		putc('\n', stderr);
	}
}


void
mark_covered(const char fig, int array[8][8], const int i_, const int j_)
{
	int i = i_, j = j_;
	int a = 0;

	if (fig == ROOK) {
		for (a = 0; a < 4; ++a) {
			for (i = i_ + rook_dir_i[a], j = j_ + rook_dir_j[a];
			     i >= 0 && i < 8 && j >= 0 && j <8 && array[i][j] != 2;
			     i += rook_dir_i[a], j += rook_dir_j[a]) {
				array[i][j] = 1;
			}
		}

		(void) fprintf(stderr, "ROOK  : i_ = %d , j_ = %d\n", i_, j_);
		_print_map(array);
		(void) fprintf(stderr, "\n\n");
	} else if (fig == BISHOP) {
		for (a = 0; a < 4; ++a) {
			for (i = i_ + bishop_dir_i[a], j = j_ + bishop_dir_j[a];
			     i >= 0 && j >= 0 && i < 8 && j < 8 && array[i][j] != 2;
			     i += bishop_dir_i[a], j += bishop_dir_j[a]) {
				array[i][j] = 1;
			}
		}

		(void) fprintf(stderr, "BISHOP: i_ = %d , j_ = %d\n", i_, j_);
		_print_map(array);
		(void) fprintf(stderr, "\n\n");
	}
}


int
main(void)
{
	int figures[8][8], covered[8][8], result = 0;
	char fig;
	int i, j;

	freopen("chess.in", "r", stdin);
	freopen("chess.out", "w", stdout);

	for (i = 0; i < 8; ++i) {
		j = 0;
		while (j < 8) {
			fig = getchar();
			switch (fig) {
				case '\n':
					continue;
				case 'R':
					figures[i][j] = ROOK;
					covered[i][j] = 2;
					break;
				case 'B':
					figures[i][j] = BISHOP;
					covered[i][j] = 2;
					break;
				case '*':
					figures[i][j] = 0;
					covered[i][j] = 0;
					break;
				default:
					--j;
			}
			j++;
		}
	}

	_print_map(figures); putc('\n', stderr);
	_print_map(covered); putc('\n', stderr);
	for (i = 0; i < 8; ++i)
		for (j = 0; j < 8; ++j) {
			if (figures[i][j] != '*') {
				mark_covered(figures[i][j], covered, i, j);
			}
		}

	for (i = 0; i < 8; ++i)
		for (j = 0; j < 8; ++j)
			if (covered[i][j] == 0)
				++result;

	printf("%d\n", result);

	return 0;
}
